package com.example.demo.tools;

import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

import java.util.ArrayList;
import java.util.List;

public class ValidationHandle {


    public static List<String> getErrors(BindingResult result){
        List<FieldError> FieldErrors = result.getFieldErrors();
        ArrayList<String> errors = new ArrayList<>();
        for(FieldError error: FieldErrors){
            errors.add(error.getDefaultMessage());
        }
        return errors;
    }
}
